﻿package com.game.view.component.dropItem
{
	import base.BaseHero;
	
	import com.dusk.game.Logger;
	import com.dusk.util.ResUtil;
	import com.game.data.vo.EquipmentVO;
	
	import flash.display.Bitmap;
	import flash.display.MovieClip;
	
	public class DropEquipment extends DropItemBase
	{
		
		public function DropEquipment(equipId:String = "")
		{
			super();
			if (equipId)
			{
				setEquipId(equipId)
			}
		}
		
		private var _equipmentId:String;
		
		public function setEquipId(equipId:String):void
		{
			_equipmentId = equipId;
			var bitmap:Bitmap = ResUtil.getImageBitmap("fall_" + _equipmentId);
			bitmap.x = -bitmap.width / 2;
			bitmap.y = -bitmap.height;
			addChild(bitmap);
			addPickFunc(pickEquip);
		}
		
		private function pickEquip(bh:BaseHero):void
		{
			var equip:EquipmentVO = gc.configManager.equipProxy.findByName(_equipmentId);
			if (equip == null)
			{
				Logger.logError("掉落物ID不存在: " + _equipmentId, this);
				return;
			}
			switch (equip.type)
			{
				case "zbfj":
				case "zbwq":
				case "zbsp":
				case "zbfb":
					if (bh.getPlayer().bagEquipList.length >= 125)
					{
						return;
					}
					else
					{
						equip.missUpAttribute();
						bh.getPlayer().bagEquipList.push(equip);
						break;
					}
				case "zbwp":
				case "wpqhs":
					if (bh.getPlayer().bagStuffList.length < 125)
					{
						gc.putQhsInBackPack(bh.getPlayer(), _equipmentId);
						break;
					}
					break;
				case "zbsz":
					if (bh.getPlayer().bugConsumeList.length < 125)
					{
						bh.getPlayer().bugConsumeList.push(equip);
						break;
					}
					break;
			}
		}
	}
}
